package com.baoyouqun.controller.weixin;

import cn.dev33.satoken.stp.StpUtil;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baoyouqun.base.PageResponse;
import com.baoyouqun.domain.CreateCmd.ReportRecordCreateCmd;
import com.baoyouqun.domain.Query.ReportRecordQuery;
import com.baoyouqun.domain.VO.ReportRecordVO;
import com.baoyouqun.service.ReportRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/wx/reportRecord")
@Api(tags = "举报记录表（用户举报各类对象的记录及处理信息）管理接口")
public class WxReportRecordController {

    @Resource
    private ReportRecordService reportRecordService;

    @PostMapping("create")
    @ApiOperation("新增举报记录表（用户举报各类对象的记录及处理信息）")
    public SingleResponse<ReportRecordVO> create(@Valid @RequestBody ReportRecordCreateCmd cmd) {
        cmd.setUserId(StpUtil.getLoginIdAsString());
        return reportRecordService.create(cmd);
    }

    @DeleteMapping("delete")
    @ApiOperation("根据ID删除举报记录表（用户举报各类对象的记录及处理信息）")
    public Response delete(String id) {
        reportRecordService.removeById(id);
        return Response.buildSuccess();
    }

    @GetMapping("getById")
    @ApiOperation("根据ID查询举报记录表（用户举报各类对象的记录及处理信息）")
    public SingleResponse<ReportRecordVO> selectById(String id) {
        return SingleResponse.of(reportRecordService.selectById(id));
    }

    @GetMapping("page")
    @ApiOperation("分页查询举报记录表（用户举报各类对象的记录及处理信息）")
    public PageResponse<ReportRecordVO> page(ReportRecordQuery query) {
        query.setUserId(StpUtil.getLoginIdAsString());
        IPage<ReportRecordVO> page = reportRecordService.pageVo(query);
        return PageResponse.of(page.getRecords(), page.getTotal(), page.getCurrent(), page.getSize());
    }
}